Skip to content

feat: use gradual 1.5x backoff for Stellar resubmission#730

Merged
zeljkoX merged 2 commits into
mainfrom
stellar-retry-backoff
Mar 31, 2026
Merged

feat: use gradual 1.5x backoff for Stellar resubmission#730
zeljkoX merged 2 commits into
mainfrom
stellar-retry-backoff

Conversation

@zeljkoX
Copy link
Copy Markdown
Collaborator

@zeljkoX zeljkoX commented Mar 27, 2026

Summary

  • Reduce Stellar resubmission base interval from 15s to 10s (~2 ledgers) to start retrying sooner after TRY_AGAIN_LATER and INSUFFICIENT_FEE errors
  • Replace 2x exponential backoff with gradual 1.5x growth factor: 10s → 15s → 22s → 33s → 50s → 75s → 113s → 120s (capped)
  • Lower max interval cap from 180s to 120s for more frequent retries on long-lived transactions
  • Add growth_factor parameter to compute_resubmit_backoff_interval() with guard against infinite loops when factor ≤ 1.0

Test plan

  • All 9 backoff unit tests pass (including new edge-case test for factor ≤ 1.0)
  • All 45 Stellar status handler tests pass
  • All 16 Stellar submit tests pass
  • Simulate TRY_AGAIN_LATER via WireMock and verify shorter retry intervals in logs

🤖 Generated with Claude Code

Summary by CodeRabbit

Chores

  • Tuned Stellar transaction resubmission timing to enable faster initial retry attempts while maintaining a reasonable maximum retry interval
  • Refined retry backoff progression strategy for improved transaction submission reliability

@zeljkoX zeljkoX requested a review from a team as a code owner March 27, 2026 10:02
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 27, 2026

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d5cacfbe-8c03-44a8-974f-7508eb1376ff

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

The PR refactors Stellar transaction resubmission timing by introducing a configurable growth factor parameter (1.5) for backoff intervals. It reduces the base interval from 15s to 10s, caps the maximum at 120s, and replaces the exponential backoff algorithm with a tiered growth mechanism.

Changes

Cohort / File(s) Summary
Resubmission Constants
src/constants/stellar_transaction.rs
Updated timing constants: base interval reduced from 15s to 10s, max interval reduced from 180s to 120s, and added new STELLAR_RESUBMIT_GROWTH_FACTOR constant (1.5) to define per-tier backoff multiplier.
Status Handler & Tests
src/domain/transaction/stellar/status.rs
Imported and integrated STELLAR_RESUBMIT_GROWTH_FACTOR into backoff computations for Sent and Submitted transaction states; updated test expectations and comments to reflect new tiered backoff schedule (10s → 15s → 22s → 33s → 50s → 75s → 113s → 120s).
Backoff Computation Algorithm
src/domain/transaction/stellar/utils.rs
Replaced exponential backoff formula with tiered growth mechanism accepting growth_factor parameter; added guard for invalid factors; rewrote all unit tests with new interval expectations and added coverage for edge cases.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • PR #695: Earlier change that this PR builds upon, modifying the Stellar resubmit backoff algorithm and introducing related constants.
  • PR #668: Modifies Stellar resubmission timing constants and related status/test logic in the same modules.
  • PR #665: Updates Stellar resubmission behavior in the same affected modules (constants and status handler).

Suggested labels

cla: allowlist

Suggested reviewers

  • tirumerla
  • NicoMolinaOZ
  • collins-w

Poem

🐰 Hops with joy at tiered growth so fine,
Backoff intervals now align,
From exponential to gentle climb,
Stellar resubmit, perfectly timed!
Factor 1.5, oh what delight,
A smoother retry through the night!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description includes a detailed summary of changes and testing results, but is missing the required checklist items (related issues reference and unit tests acknowledgment) from the template. Add the missing checklist section with proper checkbox items for related issues and unit tests confirmation as specified in the template.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: replacing exponential backoff with a 1.5x gradual growth factor for Stellar resubmission.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch stellar-retry-backoff

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates Stellar transaction resubmission timing to retry sooner and more frequently by switching from 2x exponential backoff to a gradual 1.5x growth backoff with a lower cap.

Changes:

  • Add growth_factor to compute_resubmit_backoff_interval() and implement gradual tiered backoff (capped).
  • Update Stellar status handlers to use the new backoff parameters/constants.
  • Adjust Stellar resubmission constants (base interval 10s, cap 120s) and update unit tests accordingly.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
src/domain/transaction/stellar/utils.rs Implements growth-factor-based backoff and updates/adds unit tests.
src/domain/transaction/stellar/status.rs Passes growth factor into backoff computation and updates related test expectations/comments.
src/constants/stellar_transaction.rs Updates resubmission timing constants and introduces STELLAR_RESUBMIT_GROWTH_FACTOR.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/domain/transaction/stellar/utils.rs Outdated
Comment thread src/domain/transaction/stellar/utils.rs Outdated
Comment thread src/constants/stellar_transaction.rs Outdated
Comment thread src/domain/transaction/stellar/utils.rs
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/domain/transaction/stellar/status.rs`:
- Around line 454-465: The backoff tier is being computed from total_age
(get_age_since_created) but compared to age_since_last_submit
(get_age_since_sent_or_created), causing tiers to jump after sent_at is updated;
change the logic in the resubmit path (the block using
compute_resubmit_backoff_interval with STELLAR_RESUBMIT_BASE_INTERVAL_SECONDS /
_MAX_INTERVAL_SECONDS / _GROWTH_FACTOR) so the tier is derived from
age_since_last_submit (or from an explicit retry counter / persisted retry_tier
on the transaction) rather than created_at; ensure
compute_resubmit_backoff_interval is called with the correct age input (or
replace it by computing the next interval from retry count/previous interval)
and apply the resulting backoff check against age_since_last_submit, and mirror
the same fix at the other occurrence around lines 603-613 to keep behavior
consistent.

In `@src/domain/transaction/stellar/utils.rs`:
- Around line 1325-1344: Add an early guard that rejects non-positive
base_interval_secs before using it in the loop: check if base_interval_secs <= 0
and return None (or otherwise signal invalid input) so tier_end and interval are
never initialized with zero/negative values; update the helper that uses
base_interval_secs, growth_factor, max_interval_secs, tier_end and interval to
perform this guard immediately after the existing age_secs check and before
computing interval/tier_end.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a3354b4c-f830-49b7-b92a-dfac45a53f2b

📥 Commits

Reviewing files that changed from the base of the PR and between d5c5f13 and 71af8db.

📒 Files selected for processing (3)
  • src/constants/stellar_transaction.rs
  • src/domain/transaction/stellar/status.rs
  • src/domain/transaction/stellar/utils.rs

Comment thread src/domain/transaction/stellar/status.rs
Comment thread src/domain/transaction/stellar/utils.rs Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.24%. Comparing base (672ee6d) to head (1e63d46).
⚠️ Report is 14 commits behind head on main.

Additional details and impacted files
Flag Coverage Δ
ai 0.00% <0.00%> (ø)
dev 90.24% <100.00%> (+0.04%) ⬆️
properties 0.01% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

@@            Coverage Diff             @@
##             main     #730      +/-   ##
==========================================
+ Coverage   90.20%   90.24%   +0.04%     
==========================================
  Files         289      289              
  Lines      120730   121302     +572     
==========================================
+ Hits       108905   109474     +569     
- Misses      11825    11828       +3     
Files with missing lines Coverage Δ
src/constants/stellar_transaction.rs 40.00% <ø> (ø)
src/domain/transaction/stellar/status.rs 95.72% <100.00%> (+0.09%) ⬆️
src/domain/transaction/stellar/utils.rs 90.66% <100.00%> (+0.22%) ⬆️

... and 4 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

- Use half-open intervals in doc comments to match tier boundary behavior
- Guard non-positive base_interval_secs and max_interval_secs (return None)
- Rename test to reflect min(base, max) fallback for invalid growth factor
- Fix "exponential backoff" wording in constants doc comment

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@tirumerla tirumerla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@zeljkoX zeljkoX merged commit 0795504 into main Mar 31, 2026
26 checks passed
@zeljkoX zeljkoX deleted the stellar-retry-backoff branch March 31, 2026 05:30
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 31, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants